<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/User.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<mesoBoard.Data.Message>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<script type="text/javascript">
    $(document).ready(function () {
        $("#select_all").click(function () {
            $checkall = $("#select_all");
            if ($checkall.attr('checked')) {
                $("." + $checkall.attr("class")).attr('checked', true);
            } else {
                $("." + $checkall.attr("class")).attr('checked', false);
            }
        });
    });
</script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <% using(Html.BeginForm()) { %>

        <fieldset>
            <legend><%= Html.ThemeImage("full_inbox.png") %> Inbox</legend>
            
            <table class="form_table">
                <tr>
                    <th style="width: 20px"><input type="checkbox" id="select_all" class="msg_checkbox"  /></th>
                    <th style="width: 20px"></th>
                    <th>From</th><th>Subject</th>
                    <th>Message</th>
                    <th style="width: 120px">Date</th>
                </tr>

                <% if (Model != null) {
                    int i = 0;
                    foreach (var msg in Model) { %>
                        <% if(msg.IsRead) {%>
                        <tr class="<%= i++ % 2 == 0 ? "" : "bg_color3" %>">
                        <%} else{ %>
                        <tr class="first_post">
                        <%} %>
                        <td><input type="checkbox" class="msg_checkbox" name="msgID" value="<%=msg.MessageID%>" /></td>
                        <td>
                        <img src="<%= msg.IsRead ?  Url.ThemeContent("~/Images/message.png") : Url.ThemeContent("~/Images/new_message.png") %>" alt="<%= msg.IsRead ? "Message" : "New Message" %>" />
                        </td>
                        <td style="width: 120px">
                        <a href="<%= Url.Action("ViewMessage", new {MessageID = msg.MessageID}) %>">
                        <%= msg.UserFrom.Username %>
                        </a>
                        </td>
                        <td>
                        <a href="<%= Url.Action("ViewMessage", new {MessageID = msg.MessageID}) %>">
                        <%= msg.Subject.Shorten(18) %>
                        </td>
                        <td>
                        <a href="<%= Url.Action("ViewMessage", new {MessageID = msg.MessageID}) %>">
                        <%= msg.Text.Shorten(40) %>
                        </a>
                        </td>
                        <td><%= Html.RelativeDate(msg.DateSent) %></td>
                        </tr>
                   <%}%>
                        <tr><td colspan="6"><% Html.RenderPartial("MessageTableActions"); %></td></tr>
                <% } else { %>
                    <tr><td colspan="6" align="center">No Messages</td></tr>
                <%} %>
            </table>
        </fieldset>

    <% } %>
</asp:Content>

